<template>
  <div class="person">
    <h2>我是Person组件</h2>
    <h3>姓名：{{name}}</h3>
    <h3>年龄：{{age}}</h3>
  </div>
</template>

<script>
  export default {
    name:'Person',
    data() {
        return {
            name:'张三',
            age:18
        }
    },
    methods: {
      chi(value){
        console.log('我是Person组件',value)
      }
    },
    created() {
      this.$bus.$on('huoguo',this.chi)
    },
    beforeDestroy(){
      this.$bus.$off('huoguo')
    }
  }
</script>

<style scoped>
    .person {
        background-color: skyblue;
        padding: 20px;
    }
</style>